//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.jooq;

import java.util.EnumSet;
import java.util.Set;

public enum SQLDialect {
    /** @deprecated */
    @Deprecated
    SQL99("", false),
    DEFAULT("", false),
    CUBRID("CUBRID", false),
    DERBY("Derby", false),
    FIREBIRD("Firebird", false),
    FIREBIRD_2_5("Firebird", false, FIREBIRD, (SQLDialect)null),
    FIREBIRD_3_0("Firebird", false, FIREBIRD, FIREBIRD_2_5),
    H2("H2", false),
    HSQLDB("HSQLDB", false),
    MARIADB("MariaDB", false),
    MYSQL("MySQL", false),
    MYSQL_5_7("MySQL", false, MYSQL, (SQLDialect)null),
    MYSQL_8_0("MySQL", false, MYSQL, MYSQL_5_7),
    POSTGRES("Postgres", false),
    POSTGRES_9_3("Postgres", false, POSTGRES, (SQLDialect)null),
    POSTGRES_9_4("Postgres", false, POSTGRES, POSTGRES_9_3),
    POSTGRES_9_5("Postgres", false, POSTGRES, POSTGRES_9_4),
    POSTGRES_10("Postgres", false, POSTGRES, POSTGRES_9_5),
    SQLITE("SQLite", false),
    ACCESS("Access", true),
    ACCESS2013("Access", true, ACCESS),
    ASE("ASE", true),
    AURORA_MYSQL("Aurora MySQL", true),
    AURORA_POSTGRES("Aurora Postgres", true),
    DB2("DB2", true),
    DB2_9("DB2", true, DB2),
    DB2_10("DB2", true, DB2, DB2_9),
    DB2_11("DB2", true, DB2, DB2_10),
    HANA("Hana", true),
    INFORMIX("Informix", true),
    INGRES("Ingres", true),
    ORACLE("Oracle", true),
    ORACLE10G("Oracle", true, ORACLE),
    ORACLE11G("Oracle", true, ORACLE, ORACLE10G),
    ORACLE12C("Oracle", true, ORACLE, ORACLE11G),
    /** @deprecated */
    @Deprecated
    POSTGRESPLUS("PostgresPlus", true),
    REDSHIFT("Redshift", true),
    SQLSERVER("SQLServer", true),
    SQLSERVER2008("SQLServer", true, SQLSERVER),
    SQLSERVER2012("SQLServer", true, SQLSERVER, SQLSERVER2008),
    SQLSERVER2014("SQLServer", true, SQLSERVER, SQLSERVER2012),
    SQLSERVER2016("SQLServer", true, SQLSERVER, SQLSERVER2014),
    SQLSERVER2017("SQLServer", true, SQLSERVER, SQLSERVER2016),
    SQLDATAWAREHOUSE("SQLDataWarehouse", true),
    SYBASE("Sybase", true),
    TERADATA("Teradata", true),
    VERTICA("Vertica", true);

    private static final SQLDialect[] FAMILIES;
    private final String name;
    private final boolean commercial;
    private final SQLDialect family;
    private SQLDialect predecessor;
    private final SQLDialect.ThirdParty thirdParty;

    private SQLDialect(String name, boolean commercial) {
        this(name, commercial, (SQLDialect)null, (SQLDialect)null);
    }

    private SQLDialect(String name, boolean commercial, SQLDialect family) {
        this(name, commercial, family, (SQLDialect)null);
    }

    private SQLDialect(String name, boolean commercial, SQLDialect family, SQLDialect predecessor) {
        this.name = name;
        this.commercial = commercial;
        this.family = family == null ? this : family;
        this.predecessor = predecessor == null ? this : predecessor;
        if (family != null) {
            family.predecessor = this;
        }

        this.thirdParty = new SQLDialect.ThirdParty();
    }

    public final boolean commercial() {
        return this.commercial;
    }

    public final SQLDialect family() {
        return this.family;
    }

    public final boolean isFamily() {
        return this == this.family;
    }

    public final SQLDialect predecessor() {
        return this.predecessor;
    }

    public final boolean precedes(SQLDialect other) {
        if (this.family != other.family) {
            return false;
        } else {
            for(SQLDialect candidate = other; candidate != null; candidate = candidate.predecessor()) {
                if (this == candidate) {
                    return true;
                }

                if (candidate == candidate.predecessor()) {
                    return false;
                }
            }

            return false;
        }
    }

    public final boolean supports(SQLDialect other) {
        if (this.family != other.family) {
            return false;
        } else {
            return !this.isFamily() && !other.isFamily() ? other.precedes(this) : true;
        }
    }

    public final String getName() {
        return this.name;
    }

    public final String getNameLC() {
        return this.name == null ? null : this.name.toLowerCase();
    }

    public final String getNameUC() {
        return this.name == null ? null : this.name.toUpperCase();
    }

    public static final SQLDialect[] families() {
        return (SQLDialect[])FAMILIES.clone();
    }

    public final SQLDialect.ThirdParty thirdParty() {
        return this.thirdParty;
    }

    static {
        Set<SQLDialect> set = EnumSet.noneOf(SQLDialect.class);
        SQLDialect[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            SQLDialect dialect = var1[var3];
            set.add(dialect.family());
        }

        FAMILIES = (SQLDialect[])set.toArray(new SQLDialect[0]);
    }

    public final class ThirdParty {
        public ThirdParty() {
        }

        public final String springDbName() {
            switch(SQLDialect.this.family) {
            case ASE:
                return "Sybase";
            case DB2:
                return "DB2";
            case HANA:
                return "Hana";
            case INFORMIX:
                return "Informix";
            case ORACLE:
                return "Oracle";
            case SQLDATAWAREHOUSE:
            case SQLSERVER:
                return "MS-SQL";
            case DERBY:
                return "Derby";
            case H2:
                return "H2";
            case HSQLDB:
                return "HSQL";
            case MARIADB:
            case MYSQL:
                return "MySQL";
            case POSTGRES:
                return "PostgreSQL";
            default:
                return null;
            }
        }

        public final String hibernateDialect() {
            switch(SQLDialect.this) {
            case ASE:
                return "org.hibernate.dialect.SybaseASE15Dialect";
            case DB2:
            case DB2_9:
            case DB2_10:
                return "org.hibernate.dialect.DB2Dialect";
            case HANA:
                return "org.hibernate.dialect.HANARowStoreDialect";
            case INFORMIX:
                return "org.hibernate.dialect.InformixDialect";
            case ORACLE:
            case ORACLE12C:
                return "org.hibernate.dialect.Oracle12cDialect";
            case SQLDATAWAREHOUSE:
            case SQLSERVER2008:
                return "org.hibernate.dialect.SQLServer2008Dialect";
            case SQLSERVER:
            case SQLSERVER2012:
            case SQLSERVER2014:
            case SQLSERVER2016:
            case SQLSERVER2017:
                return "org.hibernate.dialect.SQLServer2012Dialect";
            case DERBY:
                return "org.hibernate.dialect.DerbyTenSevenDialect";
            case H2:
                return "org.hibernate.dialect.H2Dialect";
            case HSQLDB:
                return "org.hibernate.dialect.HSQLDialect";
            case MARIADB:
            case MYSQL:
                return "org.hibernate.dialect.MySQL5Dialect";
            case POSTGRES:
            case POSTGRES_9_4:
            case POSTGRES_9_5:
            case POSTGRES_10:
                return "org.hibernate.dialect.PostgreSQL94Dialect";
            case ACCESS:
            case ACCESS2013:
                return null;
            case INGRES:
                return "org.hibernate.dialect.Ingres10Dialect";
            case ORACLE10G:
            case ORACLE11G:
                return "org.hibernate.dialect.Oracle10gDialect";
            case REDSHIFT:
                return "org.hibernate.dialect.PostgreSQL81Dialect";
            case SYBASE:
                return "org.hibernate.dialect.SybaseAnywhereDialect";
            case TERADATA:
                return "org.hibernate.dialect.TeradataDialect";
            case VERTICA:
                return null;
            case CUBRID:
                return "org.hibernate.dialect.CUBRIDDialect";
            case FIREBIRD:
                return "org.hibernate.dialect.FirebirdDialect";
            case POSTGRES_9_3:
                return "org.hibernate.dialect.PostgreSQL92Dialect";
            case SQLITE:
                return null;
            default:
                return null;
            }
        }
    }
}
